<form id="form-cron" method="post" data-oc-toggle="ajax" data-oc-load="{{ action }}" data-oc-target="#cron">
  <div class="table-responsive">
    <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th class="text-center" style="width: 1px;"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', $(this).prop('checked'));" class="form-check-input"/></th>
          <th><a href="{{ sort_code }}"{% if sort == 'code' %} class="{{ order|lower }}"{% endif %}>{{ column_code }}</a></th>
          <th><a href="{{ sort_cycle }}"{% if sort == 'cycle' %} class="{{ order|lower }}"{% endif %}>{{ column_cycle }}</a></th>
          <th><a href="{{ sort_action }}"{% if sort == 'action' %} class="{{ order|lower }}"{% endif %}>{{ column_action }}</a></th>
          <th class="d-none d-lg-table-cell"><a href="{{ sort_date_added }}"{% if sort == 'date_added' %} class="{{ order|lower }}"{% endif %}>{{ column_date_added }}</a></th>
          <th class="d-none d-lg-table-cell"><a href="{{ sort_date_modified }}"{% if sort == 'date_modified' %} class="{{ order|lower }}"{% endif %}>{{ column_date_modified }}</a></th>
          <th class="text-end">{{ column_action }}</th>
        </tr>
      </thead>
      <tbody>
        {% if crons %}
          {% for cron in crons %}
            <tr>
              <td class="text-center"><input type="checkbox" name="selected[]" value="{{ cron.cron_id }}" class="form-check-input"/></td>
              <td>{{ cron.code }}</td>
              <td>{{ cron.cycle }}</td>
              <td>{{ cron.action }}</td>
              <td class="d-none d-lg-table-cell">{{ cron.date_added }}</td>
              <td class="d-none d-lg-table-cell">{{ cron.date_modified }}</td>
              <td class="text-end text-nowrap">
                {% if cron.description %}
                  <button type="button" data-bs-toggle="modal" data-bs-target="#modal-cron-{{ cron.cron_id }}" class="btn btn-info"><i class="fa-solid fa-info-circle"></i></button>
                {% else %}
                  <button type="button" class="btn btn-info" disabled><i class="fa-solid fa-info-circle"></i></button>
                {% endif %}
                <button type="button" value="{{ cron.run }}" data-bs-toggle="tooltip" title="{{ button_run }}" class="btn btn-warning"><i class="fa-solid fa-play"></i></button>
                {% if not cron.status %}
                  <button type="button" value="{{ cron.enable }}" data-bs-toggle="tooltip" title="{{ button_enable }}" class="btn btn-success"><i class="fa-solid fa-plus-circle"></i></button>
                {% else %}
                  <button type="button" value="{{ cron.disable }}" data-bs-toggle="tooltip" title="{{ button_disable }}" class="btn btn-danger"><i class="fa-solid fa-minus-circle"></i></button>
                {% endif %}</td>
            </tr>
          {% endfor %}
        {% else %}
          <tr>
            <td class="text-center" colspan="7">{{ text_no_results }}</td>
          </tr>
        {% endif %}
      </tbody>
    </table>
  </div>
  <div class="row">
    <div class="col-sm-6 text-start">{{ pagination }}</div>
    <div class="col-sm-6 text-end">{{ results }}</div>
  </div>
</form>
{% for cron in crons %}
  {% if cron.description %}
    <div id="modal-cron-{{ cron.cron_id }}" class="modal">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title"><i class="fa-solid fa-info-circle"></i> {{ text_info }}</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
          </div>
          <div class="modal-body"><textarea rows="5" class="form-control" readonly>{{ cron.description }}</textarea></div>
        </div>
      </div>
    </div>
  {% endif %}
{% endfor %}